<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="org.apache.commons.lang.StringUtils,com.hz.supermanage.bean.*,com.hz.framework.util.BusinessException" %>
<jsp:useBean id="dao" class="com.hz.supermanage.dao.OrganizationDao" />
<%
request.setCharacterEncoding("UTF-8");
	String body="";
    try {
        String empId = request.getParameter("empId");
        String posId = request.getParameter("posId");
        String deptId = request.getParameter("deptId");
        String orgId = request.getParameter("orgId");
        String posType = request.getParameter("posType");
        if (StringUtils.isBlank(empId)) {
             throw new BusinessException("用户标识不能为空");
        }

        if (StringUtils.isEmpty(posId)) {
            throw new BusinessException("岗位标识不能为空");
        }

        if (StringUtils.isEmpty(deptId)) {
            throw new BusinessException("部门标识不能为空");
        }

        if (StringUtils.isEmpty(orgId)) {
            throw new BusinessException("岗位标识不能为空");
        }

        if (StringUtils.isEmpty(posType)) {
            throw new BusinessException("岗位类型不能为空");
        }
        
        //if (emCheck.isHasResult()) {
        //   throw new BusinessException("用户已经在该岗位有任职工作，请重新选择");
        //}

        //增加任职表中内容
        HzsysEmpholdpost emEmpPos = new HzsysEmpholdpost();
        emEmpPos.setOrgid(orgId);
        emEmpPos.setDepid(deptId);
        emEmpPos.setPosid(posId);
        emEmpPos.setPerid(empId);
        emEmpPos.setPtype(posType);
        
        dao.insertinfor(emEmpPos);

        body = "任职成功";
    } catch (Exception ex) {
    	body = "任职失败";
        throw new BusinessException("增加任职失败", ex);
    }

%>

<html>
<head>
    <%@ include file="../inc/action_components.jsp" %>
</head>

<body tt.action.result="true" tt.msg="<%=body %>">
<script>
    function afterSuccess() {
      _parent.__close();
      __invoke(_parent, "onRenZhiFinish");
    }
</script>
</body>
</html>